home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boostrs.arc / DOWS.ASM < prev    next >
Assembly Source File  |  1980-01-01  |  2KB  |  109 lines

  1. ;**************************************************
  2. ;
  3. ;       Function DowS ( MM, DD, CCYY : Integer) :
  4. ;                        DowString;
  5. ;
  6. ;               DowString is Type string[9];
  7. ;               Returns day of week for any
  8. ;               valid Gregorian date.
  9. ;
  10. ;**************************************************
  11. Dow00    Proc
  12.     push    bp
  13.     mov    bp,sp
  14.     push    ds
  15.     call    nothing
  16.     jmp    Next1
  17. ;
  18. table    db    0,3,2,5,0,3,5,1,4,6,2,4
  19. ;
  20. Next1:
  21.     add    bx,3
  22.     mov    di,bx
  23.     mov    bx,[bp+8]    ; MM
  24.     mov    cx,[bp+6]    ; DD
  25.     mov    dx,[bp+4]    ; CCYY
  26. ;
  27.     cmp    bx,3        ; MM < 3?
  28.     jae    Dow1
  29.     dec    dx        ; CCYY-1
  30. Dow1:    add    di,bx
  31.     dec    di
  32.     add    cl,cs:[di] ; DD=DD +
  33.                          ;    Table(MM)
  34.     mov    ax,dx
  35.     mov    bx,100
  36.     xor    bh,bh
  37.     div    bl        ; CC=CCYY \ 100
  38. ;                                 CC in al
  39. ;                                 YY in ah
  40.     push    cx        ; save
  41.     push    ax        ; save DD
  42.     mov    cl,2
  43.     ror    ah,cl
  44.     mov    cl,6
  45.     shr    ah,cl        ; YY MOD 4
  46.     mov    bl,ah        ; Save in bl
  47. ;
  48.         pop     ax
  49.         mov     cl,2
  50.         ror     al,cl
  51.         mov     cl,6
  52.         shr     al,cl           ; CC MOD 4
  53. ;
  54.     mov    cl,2
  55.     mov    dl,ah
  56.     shr    dl,cl        ; YY \ 4
  57. ;
  58. ;    bl = Number Reg years since last leap year
  59. ;    al = Number Centuries since last 400-yr cycle
  60. ;    ah = Year (e.g., for 1985, ah = 85)
  61. ;    dl = Leap years since start of century
  62. ;
  63.     pop    cx
  64.     add    al,dl        ; Leap + Cent
  65.     mov    bh,5
  66.     mul    bh
  67.     xor    bh,bh
  68.     add    ax,bx
  69.     add    ax,cx
  70.     mov    dx,7
  71.     div    dl
  72.     mov    al,ah
  73.     xor    ah,ah
  74.     call    nothing
  75.     jmp    next2
  76. days    db    'Sunday   ',
  77.     db    'Monday   ',
  78.     db    'Tuesday  ',
  79.     db    'Wednesday',
  80.     db    'Thursday ',
  81.     db    'Friday   ',
  82.     db    'Saturday '
  83. ;
  84. nothing proc
  85.     mov    bx,sp
  86.     mov    bx,ss:[bx]
  87.     ret
  88. nothing endp
  89. ;
  90. next2    add    bx,3
  91.     mov    si,bx
  92.     mov    cx,9
  93.     mul    cl
  94.     add    si,al
  95.     push    cs
  96.     pop    ds
  97.     push    ss
  98.     pop    es
  99.     mov    [bp+10],cl
  100.     lea    di,[bp+11]
  101.     cld
  102. rep    movsb
  103. ;
  104.     pop    ds
  105.     mov    sp,bp
  106.     pop    bp
  107.     ret    6
  108. Dow00    endp
  109.